package com.e3.basdoc.measure.service;

import java.util.List;

import com.e3.basdoc.measure.model.MeasureUnitModel;
import com.e3.core.base.ServiceLocator;
import com.e3.core.cache.CacheLoader;

public class MeasureUnitCacheLoader implements CacheLoader {
	
	private MeasureUnitQueryService measureQueryService;
	
	private MeasureUnitQueryService getMeasureUnitQueryService(){
		if(measureQueryService == null){
			measureQueryService = ServiceLocator.getQueryService(MeasureUnitQueryService.class);
		}
		return measureQueryService;
	}

	public void loadeData() throws Exception {
		List<MeasureUnitModel> models = getMeasureUnitQueryService().getAllMeasureUnits();
		if(models==null||models.isEmpty()){
			return;
		}
		for (MeasureUnitModel model : models) {
			MeasureUnitCacheManager.INSTANCE.put(model);
		}

	}

}
